Skip to content

Fix gateway readiness always being reported as true#111

Merged
Agent-Hellboy merged 3 commits intoAgent-Hellboy:mainfrom
aparimeet:fix_gateway
May 1, 2026
Merged

Fix gateway readiness always being reported as true#111
Agent-Hellboy merged 3 commits intoAgent-Hellboy:mainfrom
aparimeet:fix_gateway

Conversation

@aparimeet
Copy link
Copy Markdown
Contributor

Summary

Fixes misleading MCPServer status when the gateway sidecar is not in use: gatewayReady and policyReady no longer read as “ready” when spec.gateway is absent or disabled, and phase (Ready vs not) is computed in line with whether the gateway is required.

Problem

With no spec.gateway (or gateway disabled), the operator could still report gatewayReady: true and policyReady: true, and overall readiness logic treated gateway/policy as satisfied. That did not match the live Deployment (no mcp-gateway container) and was confusing in kubectl, as reported in issue #94.

Solution

gatewayReady: default false; only derived from deployment readiness when spec.gateway.enabled is true.
policyReady: false when the gateway is not enabled; unchanged behavior when enabled (ConfigMap with policy data / policy.json).
determinePhase: takes the MCPServer in addition to resourceReadiness. When the gateway is enabled, Ready requires deployment, service, ingress, gateway, policy, and canary readiness. When the gateway is disabled, Ready requires deployment, service, ingress, and canary only (gateway/policy are not part of the gate).

Testing

go test ./internal/operator/...

Notes / follow-ups

When gateway is enabled, gatewayReady still follows deployment replica readiness only; a future improvement could assert the mcp-gateway container exists in the pod template so status cannot show gateway ready if the sidecar is missing (remaining gap from the issue’s strict acceptance).

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request updates the MCPServer controller to correctly handle resource readiness when the gateway feature is disabled. It modifies the phase determination logic to conditionally include gateway and policy resources and adjusts default readiness states. Review feedback suggests further improving consistency by explicitly setting the canary readiness state when disabled and refactoring the phase determination logic for better maintainability and clarity.

Comment on lines +302 to 305
gatewayReady := false
if gatewayEnabled(mcpServer) {
gatewayReady = deploymentReady
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

For consistency with gatewayReady and policyReady, canaryReady should also be set to false when the canary feature is disabled. This ensures that the status correctly reflects that the feature is not in use and prevents a logic bug in determinePhase where a disabled canary (which currently defaults to true in checkCanaryDeploymentReady) could cause the server to report PartiallyReady instead of Pending when no other resources are ready.

gatewayReady := false
if gatewayEnabled(mcpServer) {
	gatewayReady = deploymentReady
}

if !canaryEnabled(mcpServer) {
	canaryReady = false
}

Comment thread internal/operator/controller.go Outdated
Comment on lines +318 to +324
var allReady bool
if gatewayEnabled(mcpServer) {
allReady = readiness.Deployment && readiness.Service && readiness.Ingress && readiness.Gateway && readiness.Policy && readiness.Canary
} else {
allReady = readiness.Deployment && readiness.Service && readiness.Ingress && readiness.Canary

}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The logic for determining allReady can be simplified and made more consistent by handling each optional component (Gateway and Canary) separately. This avoids duplicating the core readiness requirements and makes the function easier to maintain as more optional features are added. This refactoring also removes the unnecessary empty line at line 323.

Suggested change
var allReady bool
if gatewayEnabled(mcpServer) {
allReady = readiness.Deployment && readiness.Service && readiness.Ingress && readiness.Gateway && readiness.Policy && readiness.Canary
} else {
allReady = readiness.Deployment && readiness.Service && readiness.Ingress && readiness.Canary
}
allReady := readiness.Deployment && readiness.Service && readiness.Ingress
if gatewayEnabled(mcpServer) {
allReady = allReady && readiness.Gateway && readiness.Policy
}
if canaryEnabled(mcpServer) {
allReady = allReady && readiness.Canary
}

@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 30, 2026

Codecov Report

❌ Patch coverage is 66.66667% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 58.11%. Comparing base (35d158e) to head (bf628a7).
⚠️ Report is 6 commits behind head on main.

Files with missing lines Patch % Lines
internal/operator/controller.go 63.63% 2 Missing and 2 partials ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #111      +/-   ##
==========================================
- Coverage   58.11%   58.11%   -0.01%     
==========================================
  Files          59       59              
  Lines       10678    10684       +6     
==========================================
+ Hits         6206     6209       +3     
- Misses       3877     3878       +1     
- Partials      595      597       +2     
Flag Coverage Δ
pre-merge 58.11% <66.66%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
internal/cli/cluster.go 81.02% <100.00%> (ø)
internal/operator/controller.go 63.51% <63.63%> (-0.09%) ⬇️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@Agent-Hellboy
Copy link
Copy Markdown
Owner

Agent-Hellboy commented Apr 30, 2026

Hi @aparimeet follow https://docs.mcpruntime.org/getting-started/#3-contributor-test-mode-cluster to test it out.
Please do rebase on main before that

@Agent-Hellboy Agent-Hellboy merged commit 4de920c into Agent-Hellboy:main May 1, 2026
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants